package jzoffer;

/**
 * Author:   dengxin
 * Date:     2020/6/17 4:40 下午
 * 跳台阶，一只青蛙一次可以跳上一级台阶，也可以跳上两级台阶，求该青蛙跳上n级台阶总共有多少种跳法
 * 答案：实际仍为斐波拉契数列
 */
public class jz8 {

    private static int jumpFloor(int target) {
        if (target <= 0) {
            return 0;
        }
        int one = 1;
        int two = 2;
        if (target == 1) {
            return one;
        }
        if (target == 2) {
            return two;
        }
        int result = 0;
        for (int i=2; i<target; i++) {
            result = one + two;
            one = two;
            two = result;
        }
        return result;
    }
}
